package com.wwy.user.controller;

import com.common.domain.CommonResult;
import com.wwy.user.module.entity.User;
import com.wwy.user.module.vo.user.UserLogin;
import com.wwy.user.module.vo.user.UserSaveVo;
import com.wwy.user.service.UserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 王伟羽
 * @program: almighty
 * @description: 用户登录接口
 * @create: 2024/11/04
 */
@RestController
@RequestMapping(value = "/auth")
@Api(tags = "用户权限")
public class UserLoginController {


    @Resource
    private UserLoginService userLoginService;

    @ApiOperation(value = "用户账号密码登录")
    @PostMapping(value = "/userLogin")
    public CommonResult userLogin(@RequestBody UserLogin userLogin) {
         return userLoginService.login(userLogin);
    }

    @ApiOperation(value = "手机号注册")
    @PostMapping(value = "/userRegister")
    public CommonResult userRegister(@RequestBody UserLogin userLogin){
        return userLoginService.userRegister(userLogin);
    }

    @ApiOperation(value = "用户注册")
    @PostMapping(value = "/verifyNode")
    public CommonResult verifyNode(@RequestBody UserSaveVo user) {
        return userLoginService.register(user);
    }

    @GetMapping(value = "/sendNode")
    @ApiOperation(value = "发送验证码")
    public CommonResult sendNode(String username){
        return userLoginService.sendNode(username);
    }
}
